<template>
  <van-scroll :scroll-x="true" :scroll-y="false" eventPassthrough="vertical">
    <div class="floor" ref="floorRef">
      <div class="floor-item" v-for="item in list" :key="item.id" @click="handleClick(item)">
        <div class="floor-item-flex">
          <div class="floor-item-flex__icon">
            <img v-lazy="item.coverImgUrl" />
            <span class="listen">
              <i class="my-icon my-icon-timeout"></i>
              {{ getPlayCount(item.playCount) }}
            </span>
          </div>
          <div class="floor-item-flex__title">
            <span class="name">{{ item.name }}</span>
          </div>
        </div>
      </div>
    </div>
  </van-scroll>
</template>

<script lang="ts" setup>
import { PropType } from 'vue'
import VanScroll from '@/components/scroll/Scroll.vue';
import { useMyRouters } from '@/router';
import { getPlayCount } from '@/assets/js/util';

const { router } = useMyRouters();

defineProps({
  // 数据列表
  list: {
    type: Array as PropType<any[]>,
    default: []
  }
});

// 跳转到详情页
function handleClick(item: any) {
  router.push({
    path: '/recomdetail',
    query: {
      id: item.id || item.creativeId
    }
  });
}
</script>

<style lang="less" scoped>
.scroll {
  white-space: nowrap;
  // height: 140px;
  .floor {
    display: inline-block;
    // padding: 10px 0;
    .floor-item {
      width: 110px;
      display: inline-block;
      .floor-item-flex {
        display: flex;
        flex-direction: column;
        align-items: center;
        .floor-item-flex__icon {
          width: 100px;
          height: 100px;
          position: relative;
          img {
            width: 100%;
            height: 100%;
            border-radius: 10px;
          }
          .listen {
            display: flex;
            align-items: center;
            background-color: rgba(0, 0, 0, 0.384);
            padding: 0 8px 0 3px;
            border-radius: 10px;
            position: absolute;
            left: 5px;
            bottom: 5px;
            color: #fff;
            i {
              font-size: 23px;
            }
          }
        }
        .floor-item-flex__title {
          width: 100px;
          padding-top: 5px;
          overflow: hidden;
          span.name {
            white-space: normal;
            line-height: 18px;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
          }
        }
      }
    }
  }
}
</style>
